﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Text;

namespace demo
{
    public class ManageMenu
    {
        public ManageMenu()
        {
        }

        public static void SaveMenu()
        {
            //StreamWriter writeFile;
            //String _fileName = "Menu";
            //IsolatedStorageFile isolatedFile = IsolatedStorageFile.GetUserStoreForApplication();

            //try
            //{
            //    writeFile = new StreamWriter(new IsolatedStorageFileStream(_fileName, FileMode.Create, isolatedFile));
            //    for (int i = 0; i < 4; i++)
            //    {
            //        for (int j = 0; j < 8; j++)
            //        {
            //            writeFile.WriteLine(MainPage.MenuGame[i, j].level + " " + MainPage.MenuGame[i, j].state + " " + MainPage.MenuGame[i, j].score);
            //            //Debug.WriteLine("Save: " + MainPage.MenuGame[i, j].level + " " + MainPage.MenuGame[i, j].state + " " + MainPage.MenuGame[i, j].score);
            //        }
            //    }

            //    writeFile.Close();

            //}
            //catch (Exception ex)
            //{

            //}
        }

        public static void LoadMenu()
        {
            ////Menu m = new Menu(id, -1, true, 0);
            //String _fileName = "Menu";
            //IsolatedStorageFile isolatedFile = IsolatedStorageFile.GetUserStoreForApplication();
            //try
            //{
            //    //Debug.WriteLine("1");
            //    IsolatedStorageFileStream fileStream = isolatedFile.OpenFile(_fileName, FileMode.Open, FileAccess.Read);
            //    //Debug.WriteLine("2");
            //    using (StreamReader reader = new StreamReader(fileStream))
            //    {
            //        //Debug.WriteLine("3");
            //        // Render all parts of the screen
            //        string str;

            //        string level, state, highscore;
            //        for (int i = 0; i < 4; i++)
            //        {
            //            for (int j = 0; j < 8; j++)
            //            {
            //                str = reader.ReadLine();

            //                int lastSpaceIndex = 0;
            //                lastSpaceIndex = str.LastIndexOf(" ");
            //                highscore = str.Substring(lastSpaceIndex);
            //                String str2 = str.Substring(0, lastSpaceIndex);
            //                lastSpaceIndex = str2.LastIndexOf(" ");
            //                level = str2.Substring(0, lastSpaceIndex);

            //                state = str2.Substring(lastSpaceIndex);
            //                //Debug.WriteLine("Load: " + Int32.Parse(level)+" "+ Int32.Parse(state)+" "+ Int32.Parse(highscore));
            //                MainPage.MenuGame[i,j] = new Menu(Int32.Parse(level), Int32.Parse(state), true, Int32.Parse(highscore));
            //            }
                        
            //        }

            //        fileStream.Close();
            //    }
            //}
            //catch (Exception ex)
            //{
            //    Debug.WriteLine("4");
            //}
            ////return m;
        }
    }
}
